/*****************************************************************************/
/*	File: mmLCD.h
/*	Purpose: Contains prototypes for controlling and configuring Mentor LCD
/*	Creation Date:  6/16/2011
/*	Eng: Jason Reber
/*****************************************************************************/

#ifndef __MMLCD_H
#define __MMLCD_H
#include "GenericTypeDefs.h"

typedef union
{
    UINT16    val;
    struct
    {
        unsigned    digit0 : 4;
        unsigned    digit1 : 4;
        unsigned    digit2 : 4;
        unsigned    dispsym: 4;   //2 decimal points, +/- char
    };
} mmDisp;

void    lcd_init(void);
BOOL    mmDisplayDigits(mmDisp);
void    lcd_display_on(void);
void    lcd_display_off(void);
void 	mmLCDClear(mmDisp disp);
void 	mmDisplayOpr(void);

/*The following definitions map the LCD Glass to the seg/com registers*/
// Glass pin 1
    #define B1    SEG0COM1
    #define MINUS SEG0COM2
    
// Glass pin 2
    #define D1  SEG1COM0
    #define E1  SEG1COM1
    #define F1  SEG1COM2
    
// Glass pin 3
    #define C1  SEG2COM0
    #define G1  SEG2COM1
    #define A1  SEG2COM2
  
// Glass pin 4
    #define DP1 SEG3COM0
        
// Glass pin 5
    #define D2  SEG4COM0
    #define E2  SEG4COM1
    #define F2  SEG4COM2
    
// Glass pin 6
    #define C2  SEG5COM0
    #define G2  SEG5COM1
    #define A2  SEG5COM2

// Glass pin 7
    #define DP2  SEG6COM0
    
// Glass pin 9
    #define B3  SEG7COM1
    
// Glass pin 10
    #define C3      SEG8COM0
    #define G3      SEG8COM1
    #define A3      SEG8COM2
   
// Glass pin 11
    #define D3      SEG9COM0
    #define E3      SEG9COM1
    #define F3      SEG9COM2
    
// Glass pin 12
    #define B2      SEG10COM1
    #define CX      SEG10COM2

/*The following lines define the layout of the 7-segment display and create a
  bit structure to represent the on/off segments of the display in memory.

 AAAAAA
F      B
F      B
F      B
 GGGGGG
E      C
E      C
E      C
 DDDDDD  
 
*/
#define SEG_A   0x01
#define SEG_B   0x02
#define SEG_C   0x04
#define SEG_D   0x08
#define SEG_E   0x10
#define SEG_F   0x20
#define SEG_G   0x40
#define DP_1    0x01    //The decimal point between digit 0 and digit 1
#define DP_2    0x02    //The decimal point between digit 1 and digit 2
#define MINUS_   0x04    //The "minus" symbol
#define C1_C2    0x08    //the vertical bars above and below the "minus"

#define DIGIT_0 (SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F)
#define DIGIT_1 (SEG_B | SEG_C)
#define DIGIT_2 (SEG_A | SEG_B | SEG_G | SEG_E | SEG_D)
#define DIGIT_3 (SEG_A | SEG_B | SEG_C | SEG_G | SEG_D)
#define DIGIT_4 (SEG_F | SEG_G | SEG_C | SEG_B)
#define DIGIT_5 (SEG_A | SEG_F | SEG_G | SEG_C | SEG_D)
#define DIGIT_6 (SEG_A | SEG_F | SEG_G | SEG_C | SEG_D | SEG_E)
#define DIGIT_7 (SEG_A | SEG_B | SEG_C)
#define DIGIT_8 (SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F | SEG_G)
#define DIGIT_9 (SEG_A | SEG_B | SEG_C | SEG_F | SEG_G)


typedef union
{
    unsigned char   val;

    struct
    {
        unsigned    seg_dp : 1;
        unsigned    seg_g : 1;
        unsigned    seg_f : 1;
        unsigned    seg_e : 1;
        unsigned    seg_d : 1;
        unsigned    seg_c : 1;
        unsigned    seg_b : 1;
        unsigned    seg_a : 1;
    };
}SEVEN_SEGMENT_TYPE;



#endif // __LCD_H
